<template>
  <div class="promotion">
    <!-- 查询 -->
    <el-card shadow="never">
      <el-form label-width="100px" :inline="true" ref="formPromotion" :model="formPromotion">
        <!-- <el-form-item label="邀请人">
          <el-input v-model="formPromotion.username" size="mini"></el-input>
        </el-form-item> -->
        <el-form-item label="邀请人邮箱">
          <el-input v-model="formPromotion.inviteUserMailbox" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="被邀请人邮箱">
          <el-input v-model="formPromotion.beInvitedUserMailbox" size="mini"></el-input>
        </el-form-item>
        <!-- <el-form-item label="被邀请人">
          <el-input v-model="formPromotion.beUsername" size="mini"></el-input>
        </el-form-item> -->

        <el-form-item>
          <el-button type="primary" @click="onSubmit" size="mini">查询</el-button>
        </el-form-item>

      </el-form>
    </el-card>
    <!-- 表格 -->
    <el-card shadow="never" style="margin-top: 20px;">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="inviteTime" label="邀请时间" width="150">
        </el-table-column>
        <el-table-column prop="username" label="邀请人">
        </el-table-column>
        <el-table-column prop="inviteUserMailbox" label="邀请人邮箱" width="180">
        </el-table-column>
        <el-table-column prop="ipAddress" label="邀请人IP" width="150">
        </el-table-column>
        <el-table-column prop="beUsername" label="被邀请人">
        </el-table-column>
        <el-table-column prop="beInvitedUserMailbox" label="被邀请人邮箱" width="180">
        </el-table-column>
        <el-table-column prop="beIpAddress" label="被邀请人IP" width="150">
        </el-table-column>

      </el-table>
      <!-- 分页 -->
      <paging :page-size="formPromotion.pageSize" :total="total" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />


    </el-card>
  </div>
</template>

<script>
import { getTbInvitationListPageDTO } from '@/api/promotion'
import paging from '@/components/paging.vue'
import Cookies from "js-cookie";
import { TOKEN_KEY } from "@/constants/KEY";
import { options } from 'runjs';
// import ChangeResult from './components/ChangeResult.vue'
// import { getPromotion } from '@/api/Tradingacct'

export default {
  name: 'VueAdminIndex',
  data() {
    return {
      header: {
        Authentication: Cookies.get(TOKEN_KEY)
      },
      formPromotion: {
        inviteUserMailbox: null, //邀请人邮箱
        username: null, //邀请人姓名
        ipAddress: null, //邀请人ip
        beInvitedUserMailbox: null, //被邀请人的邮箱
        beUsername: null,
        beIpAddress: null,
        inviteTime: null,
        page: 1,
        pageSize: 10,
      },
      total: 0,
      tableData: [],
      options: [
        { id: null, name: '全部' },
        { id: 1, name: '未处理' },
        { id: 2, name: '同意' },
        { id: 3, name: '驳回' },
      ],

      id: 0
    }
  },
  components: {
    paging
  },
  mounted() {
    this.getTbInvitationListPage()
  },
  methods: {
    // 列表接口
    async getTbInvitationListPage() {
      const data = await getTbInvitationListPageDTO(this.formPromotion)
      console.log(data, '11')
      this.tableData = data.records
      this.total = data.total
    },

    // 点击查询
    onSubmit() {
      clearTimeout(this.timer) // 清理上一次的定时器
      this.timer = setTimeout(() => {
        this.formPromotion.page = 1
        this.getTbInvitationListPage()
      }, 100)
    },
    handleSizeChange(val){
      this.formPromotion.pageSize = val
      this.getTbInvitationListPage()
    },
    handleCurrentChange(val){
      this.formPromotion.page = val
      this.getTbInvitationListPage()
    },



  },


}
</script>

<style lang="scss" scoped>
@media (max-width:768px) {

  .el-form-item {
    display: flex;


  }
}
</style>